<?php

class products_m_category extends a_base_model_datamapper {

    public function __construct($id=null) {

        $this->table = 'categories_products';

        $this->has_one['category_m_category'] = array(
            'class' => 'category_m_category',
            'join_other_as' => 'category',
            'join_self_as' => 'products'
        );

        parent::__construct();
    }

    public function get_product_obj() {
        $obj = class_loader::new_obj("product_m_product");
        $obj->get_by_id($this->product_id);
        if ($obj->exists()) {
            return $obj;
        } else {
            return NULL;
        }
    }

}

?>